<?php

use App\Admin\Extensions\ChatMessage;
use App\Admin\Extensions\Weather;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;
use Dcat\Admin\Layout\Navbar;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */

Grid::resolving(function (Grid $grid) {
    $grid->disableRowSelector()->disableEditButton()->disableViewButton();
});
Show::resolving(function (Show $show) {
    $show->disableListButton()->disableEditButton()->disableDeleteButton();
});


Admin::navbar(function (Navbar $navbar) {
    //天气组件
    $navbar->left(new Weather());
    //未读消息
    //$navbar->right(new ChatMessage());
});

//这个js是为了解决使用tab 组件，点击不切换问题的
Admin::script(
    <<<JS
    Dcat.init('.nav-tabs .nav-item a', function (element, id) {
        element.css('cursor','pointer');
        element.on('click', function () {
            $(this).attr('data-target',$(this).attr('href'));
            $(this).removeAttr('href');
            $(this).tab('show')
        });
    });
JS
);





